// pages/index/index.js
const app = getApp()

Page({
  data: {
    features: [
      { name: '文具坊', emoji: '🛍️' },
      { name: '日行一善', emoji: '✨' },
      { name: '每月一捐', emoji: '📅' },
      { name: '一对一', emoji: '🤝' },
      { name: '一块捐书', emoji: '📚' },
      { name: '组队捐', emoji: '👥' },
      { name: '身边公益', emoji: '📍' },
      { name: '小红花', emoji: '🌸' }
    ],
    children: [
      {
        id: 1,
        name: '小明',
        age: 8,
        grade: '三年级',
        school: '希望小学',
        avatar: '/images/child1.jpg',
        description: '家庭困难，需要资助学费',
        donated: 1200,
        target: 3000
      },
      {
        id: 2,
        name: '小红',
        age: 10,
        grade: '五年级',
        school: '阳光小学',
        avatar: '/images/child2.jpg',
        description: '父母双亡，与奶奶相依为命',
        donated: 800,
        target: 2500
      }
    ]
  },

  onLoad() {
    console.log('首页加载')
  },

  onShow() {
    console.log('首页显示')
  },

  // 跳转到捐赠页面
  goToDonate(e) {
    const childId = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/donate/donate?childId=${childId}`
    })
  },

  // 查看孩子详情
  viewChildDetail(e) {
    const childId = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/child-detail/child-detail?childId=${childId}`
    })
  }
  ,
  // 进入受助家长操作入口
  goGuardian() {
    wx.navigateTo({ url: '/pages/guardian/guardian' })
  },
  // 功能点击
  onFeatureTap(e) {
    const name = e.currentTarget.dataset.name
    wx.showToast({ title: `${name} 敬请期待`, icon: 'none' })
  }
})
